<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%--用jsp和el来获取表单的值--%>
<%@ page import="order.pojo.admin" %>
<%@ page import="order.pojo.customer" %>
<%@ page import="order.pojo.manager" %>


<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="renderer" content="webkit">
    <title>登录</title>
    <link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/css/pintuer.css">
    <link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/css/admin.css">
      <link type="text/css" rel="shortcut icon" href="${pageContext.request.contextPath}/images/logo.jpg">
    <script src="${pageContext.request.contextPath}/js/jquery.js"></script>
    <script src="${pageContext.request.contextPath}/js/pintuer.js"></script>
    <script type="text/javascript">
        function checkForm() {
            var userName = document.getElementById("userName").value;
            var password = document.getElementById("password").value;
            var userTypes = document.getElementsByName("userType");
            var userType = null;
            for(var i=0;i<userTypes.length;i++) {
                if(userTypes[i].checked) {
                    userType=userTypes[i].value;
                    break;
                }
            }
            if (userName == null || userName == "") {
                document.getElementById("error").innerHTML = "用户名不能为空";
                return false;
            }
            if (password == null || password == "") {
                document.getElementById("error").innerHTML = "密码不能为空";
                return false;
            }
            if (userType == null || userType == "") {
                document.getElementById("error").innerHTML = "请选择用户类型";
                return false;
            }
            return true;
        }
    </script>
</head>
<body>
<div class="bg"></div>
<div class="container">
    <div class="line bouncein">
        <div class="xs6 xm4 xs3-move xm4-move">
            <div style="height:150px;"></div>
            <div class="media media-y margin-big-bottom">
            </div>
            <form action="login" method="post"  onsubmit="return checkForm()">
            <div class="panel loginbox">
                <div class="text-center margin-big padding-big-top"><h1>梧院二食堂点餐系统</h1></div>
                <div class="panel-body" style="padding:30px; padding-bottom:10px; padding-top:10px;">
                    <div class="form-group">
                        <div class="field field-icon-right">
                            <input type="text" class="input input-big" name="userName" placeholder="登录账号" data-validate="required:请填写账号" />
<%--                            required这个标签用来检查提交前是否输入了字段--%>
                            <span class="icon icon-user margin-small"></span>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="field field-icon-right">
                            <input type="password" class="input input-big" name="password" placeholder="登录密码" data-validate="required:请填写密码" />
                            <span class="icon icon-key margin-small"></span>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="field">
                            <input type="text" class="input input-big" name="code" placeholder="填写右侧的验证码" data-validate="required:请填写右侧的验证码" />
                           <img src="${pageContext.request.contextPath}/images/passcode.jpg" alt="" width="100" height="32" class="passcode" style="height:43px;cursor:pointer;" onclick="this.src=this.src+'?'">

                        </div>
                    </div>
                    <label class="radio inline">
                        <input id="admin" type="radio" name="userType" value="admin"  checked/> 系统管理员
                    </label>
                    <label class="radio inline">
                        <input id="dormManager" type="radio" name="userType" value="manager"  /> 店主
                    </label>
                    <label class="radio inline">
                        <input id="student" type="radio" name="userType" value="customer"  /> 顾客
                    </label>

                </div>
                <h4><font style="margin-left: 40px" id="error" color="red">${error }</font></h4>
                <div style="padding:30px;"><input type="submit" class="button button-block bg-main text-big input-big" value="登录"></div>
            </div>
            </form>
        </div>
    </div>
</div>

</body>
</html>
